﻿using System;
using System.Collections.Generic;
using System.Text;

namespace GeoFly
{
    public class Muskingum  
{

      public  Muskingum()
        {
        }
	
	//设置参数
     public   void SetRoutingPara(double deltaT,double Q11,double Q12,double Q21,double x,double k)
        {
            m_deltaT = deltaT;
            m_Q11 = Q11;
            m_Q12 = Q12;
            m_Q21 = Q21;
            m_X = x;
            m_K = k;		
        }

      public  double RoutingOutQ()//计算汇流流量输出
        {
            m_Q22 = 0;
	        CalcMuskRoutingCoeff();					
	        m_Q22 = C1 * m_Q11 + C2 * m_Q12 + C3 * m_Q21;
	        return m_Q22;
        }


      public  void CalcMuskRoutingCoeff()//计算汇流计算所需的系数
        { 
            double	denominator = 1;
	        denominator = m_K * (1 - m_X) + 0.5 * m_deltaT;
	        C1 = (m_X * m_K + 0.5 * m_deltaT) / denominator;
	        C2 = (0.5 * m_deltaT - m_X * m_K) / denominator;
	        C3 = (m_K * (1 - m_X) - 0.5 * m_deltaT) / denominator;
        }
	

	double	m_Q22;						
	double	m_X;					
	double	m_K;						
	

	double	m_deltaT;					
	
	double	m_Q11;						
	double	m_Q12;						
	double	m_Q21;
	
	double	C1;
	double	C2;
	double	C3;
};

}
